<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<f:loadBundle basename="messages" var="msgs" />

<h:head></h:head>

<h:body>

	<style type="text/css">
.mytop td {
	vertical-align: top;
}

.ui-widget,.ui-widget .ui-widget {
	font-size: 85%;
}

.fileupload-content {
	display: none;
}

.fileupload-buttonbar {
	border: none;
	padding: 0 0;
}

.shortList .ui-orderlist-list {
    height: 50px;
    width: 150px;
}
</style>

	<h1 class="ui-widget-header" style="font-size: larger">#{msgs.BulkMail}</h1>

	<div class="ui-widget" style="text-align: right">
		<h:form>
			<h:outputLabel value="#{msgs.Welcome}, #{loginBean.login} "
				rendered="#{loginBean.auth == true}" />
			<h:outputText value="#{msgs.AuthFail}"
				rendered="#{loginBean.auth == false}" />
			<p:commandButton value="#{msgs.Logout}" icon="ui-icon-power"
				action="#{loginBean.logout}" />
		</h:form>
	</div>

	<h:form enctype="multipart/form-data" class="ui-widget">

		<h:panelGrid>

			<h:panelGroup>
				<p:selectOneRadio value="#{mailBean.action}" layout="pageDirection">
					<f:selectItem itemValue="togroup" itemLabel="#{msgs.SendToGroup}" />
					<f:selectItem itemValue="multi" itemLabel="#{msgs.SendMulti}" />
					<f:ajax event="click" render="@form" />
				</p:selectOneRadio>
			</h:panelGroup>

			<hr />

			<h:panelGrid>
				<h:panelGroup rendered="#{mailBean.action == 'togroup'}">
					<h:outputText value="#{msgs.SelectGroups}. " />
					<h:outputText value="#{msgs.UseKeysToSelect}. " />
					<br />
					<br />
					<p:selectManyMenu label="#{msgs.SelectGroups}" filter="true"
						style="width:650px;height:200px" showCheckbox="true"
						value="#{ldapBean.selectedGroups}">
						<f:selectItems value="#{ldapBean.listGroups}" />
					</p:selectManyMenu>
				</h:panelGroup>

				<h:panelGrid columns="3" cellspacing="16"
					rendered="#{mailBean.action == 'multi'}">
					<h:panelGroup>
						<h:outputText value="#{msgs.ArchiveType} " />
						<p:selectOneMenu value="#{mailBean.archType}">
							<f:selectItem itemLabel="7z" itemValue="7z" />
							<f:selectItem itemLabel="rar" itemValue="rar" />
						</p:selectOneMenu>
					</h:panelGroup>
					<h:panelGroup>
						<h:outputText value="#{msgs.FragmentSize} " />
						<p:selectOneMenu value="#{mailBean.volumeSize}">
							<f:selectItem itemLabel="1400K" itemValue="1400K" />
							<f:selectItem itemLabel="3M" itemValue="3M" />
							<f:selectItem itemLabel="7M" itemValue="7M" />
							<f:selectItem itemLabel="15M" itemValue="15M" />
						</p:selectOneMenu>
					</h:panelGroup>
					<h:panelGroup>
						<p:fileUpload fileUploadListener="#{mailBean.handleFileUpload}"
							multiple="true" mode="advanced" auto="true"
							label="#{msgs.AddAttachment}"
							sizeLimit="#{mailBean.attMaxSize}000000" update="uploadedFiles" />
						<h:outputText value="#{msgs.Maximum} #{mailBean.attMaxSize}M" />
					</h:panelGroup>
				</h:panelGrid>
			</h:panelGrid>

			<h:panelGrid columns="2">
				<h:panelGroup>
					<h:panelGrid>
						<h:panelGroup rendered="#{mailBean.action == 'multi'}">
							<h:outputText value="#{msgs.To} " />
							<p:inputText size="64" id="email" title="#{msgs.EmailTooltip}"
								value="#{mailBean.messageAddress}" />
							<h:message for="email" style="color:red" />
							<p:tooltip for="email" />
						</h:panelGroup>
						<h:panelGroup>
							<h:outputText value="#{msgs.Subject} " />
							<p:inputText size="64" value="#{mailBean.messageSubject}" />
						</h:panelGroup>
					</h:panelGrid>
				</h:panelGroup>
				<h:panelGroup rendered="#{mailBean.action == 'multi'}">
					<h:outputText value="#{msgs.Attachment} " class="mytop" />
					<p:commandButton value="#{msgs.Remove}" icon="ui-icon-minus"
						action="#{mailBean.removeAttachment}" update="uploadedFiles" style="font-size: 75%" />
					<br />
					<h:inputTextarea value="#{mailBean.uploadedFileNames}" rows="3" cols="32" readonly="true"
						id="uploadedFiles" style="font-size: 75%"/>
				</h:panelGroup>
			</h:panelGrid>

			<h:panelGroup>
				<h:outputText value="#{msgs.Message} " />
				<br />
				<p:inputTextarea rows="8" cols="96" value="#{mailBean.messageBody}" />
			</h:panelGroup>

			<h:panelGroup rendered="#{mailBean.action == 'multi'}">
				<h:outputText value="#{msgs.SendingReport} " />
				<p:selectBooleanCheckbox value="#{mailBean.sendingReport}" />
			</h:panelGroup>

			<br />

			<h:panelGroup>
				<p:commandButton value="#{msgs.Send}" icon="ui-icon-mail-closed"
					action="#{mailBean.submit}" style="font-weight:bold" />
				<p:commandButton value="#{msgs.Reset}" type="reset" />
				<br />
				<br />
				<p:poll interval="1" async="true" global="false" />
				<p:outputPanel autoUpdate="true">
					<p:progressBar id="progress" interval="100" ajax="true"
						value="#{mailBean.progressBar}" widgetVar="pbAjax"
						rendered="#{mailBean.actionStarted == true}" />
				</p:outputPanel>
			</h:panelGroup>

		</h:panelGrid>

	</h:form>

</h:body>

</html>